<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>发布</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../js/mui.min.js"></script>
		 <script src="../js/app.js"></script>
		 <link href="../css/mui.min.css" rel="stylesheet" />
		 <style type="text/css">
		 			.mui-content{
		 				/*margin-bottom: 40px;*/  
		 			}
		 			#show_messagea li{
		 				background: #fff;
		 			}
		 			#show_messagea{
		 				background: #FAFAFA;
		 				
		 			}

		 			.p1{
		 				color: #000000;
		 				font-size: 20px;

		 				padding: 3px;
		 			}
		 			.p2{

		 				padding:0 0px 0 62px;
		 				border-radius:5px;
		 			}
table,tr,td,th{

padding: 0;

margin: 0;

}

table{

width: 100%;

border-color: #ccc;

}

table tr{

/*line-height: 30px;*/
/**/
border-color: #ccc;

}

table th,table td{
	 padding: 8px;
border-width: 1px;
 border-style: solid;
 border-color: #999999;


}

table tr:nth-child(even){
background: #ccc;
}
		 			a{ text-decoration:none;
    color:#222222;}

/*小盒子内容区的样式，display:inline-block：实现 效果*/
#con{
	margin: 1px;
}
#con .pic{ border-radius:1px;float:left; min-height:100px;box-shadow:2px 2px 6px #b5b5b5;line-height:1.2;margin: 5px;padding:2px;}
#con p{
	margin-bottom: 2px;
}
.mui-input-row label{
	padding-right: 5px;
	}
#con h5{padding:1px;margin-top: -2px;border-bottom:1px solid #ddd;}
#con h5 a{text-decoration:none;color:#999;}
body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
            background-color: black;
            text-align: center;
        }

        #crop_btn {
            color: white;
            background-color: #836FFF;
            height: 40px;
            display: inline-block;
            line-height: 40px;
            width: 110px;
            text-align: center;
            border-radius: 2px;
        }

        button{
            appearance: none;
            -webkit-appearance: none;
            border: 0;
            background: none;
        }

        #crop_circle_btn {
            color: white;
            background-color: #836FFF;
            height: 40px;
            line-height: 40px;
            width: 110px;
            text-align: center;
            border-radius: 2px;
            display: inline-block;
            margin-left: 20px;
        }

        #crop_circle_btn:active,#crop_btn:active{
            background-color: #6854e4;
        }
</style>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title">新闻发布</h1>
	</header>
<div class="mui-content">
    <form class="mui-input-group" name="myform">
    	      	    
      	    <div class="mui-input-row">
      	        <label>归类</label>
				<select id="class"style="width:65%;"onchange="getsel()">
		   		<option value="1">主创团队</option>
				<option value="2">技术团队</option>
				<option value="3">演员</option>
				<option value="4">合作机构</option>
				</select> 
      	    </div>
      	    <div class="mui-input-row">
      	        <label>是否拟定</label>
				   <select id="confirm"style="width:65%;">
				  <option value="1">拟约</option>
				  <option value="2">已签约</option>
				 </select> 
      	    </div>
      	    <div class="mui-input-row">
      	        <label name="name" >姓名</label>
      	        <input type="text" id="name" class="mui-input-clear" placeholder="请输入您的名字昵称">
      	    </div>
			<div class="mui-input-row">
      	        <label name="duty">职位/角色</label>
      	        <input type="text" id="duty" class="mui-input-clear" placeholder="导演,摄影师,联合出品人" >
      	    </div>
			<div class="" style="max-width:99%;text-align:center;"onclick="goimage()">
				    <img id="image" style="margin: 1% 8%;width: 80%;height: auto;"   src="" /><span>形象照片</span><span class="mui-badge mui-badge-primary">上传</span>
			</div>
      	    <div class="mui-input-row">
      	        <label>简介</label></div>
      	        <textarea id="synopsis"  class="mui-input-clear" placeholder="请输入不超过200字简介" maxlength="200" type="text" rows="3" cols="30"></textarea>

      	</form> <div class="mui-input-row">
      		<div id="ceshi"></div>
      	<button type="button" class="mui-btn mui-btn-blue" style="padding:7px;margin: 1%;width: 98%;font-size: 18;" onclick="tijiao()">提交</button></div>
      </div>
      <!--<div>查看数据详单>>>></div>-->
<script src="../Plugin/image/asset/transform.js"></script>
    <script src="../Plugin/image/asset/alloy-finger.js"></script>
    <script src="../Plugin/image/alloy-crop.js"></script>
    <script src="Plugin/imgupload.js"></script>
<script type="text/javascript">
	function getsel(){
	//去本地数据库读取个人发布的信息，字段key=opta.value;
var optb=document.getElementById("class");
//if(optb.value=='1'){
//	document.getElementsByName('name')[0].innerHTML='姓名';
//	document.getElementsByName('duty')[0].innerHTML='职位';
//		return false;
//}else if{
//	
//}
//var num = optb.value;
switch(optb.value){
    case '1':
    document.getElementsByName('name')[0].innerHTML='姓名';
	document.getElementsByName('duty')[0].innerHTML='职务';
	document.getElementById('duty').placeholder='制片人,导演,编剧,联合出品人';
        console.log("0")
        break;
    case '2':
    document.getElementsByName('name')[0].innerHTML='姓名';
	document.getElementsByName('duty')[0].innerHTML='职能';
	document.getElementById('duty').placeholder='制片主任,造型设计,美术';
        console.log("5")
        break;
	case '3':
    document.getElementsByName('name')[0].innerHTML='姓名';
	document.getElementsByName('duty')[0].innerHTML='饰演角色';
	document.getElementById('duty').placeholder='郭靖,黄蓉,小龙女,东方不败'
        console.log("5")
        break;
        case '4':
    document.getElementsByName('name')[0].innerHTML='公司全称';
	document.getElementsByName('duty')[0].innerHTML='职能/责任';
	document.getElementById('duty').placeholder='器材,商务,宣传,发行,赞助,后期'
        console.log("5")
        break;
    default:
    	document.getElementsByName('name')[0].innerHTML='公司全称';
		document.getElementsByName('duty')[0].innerHTML='职能/责任';
		document.getElementById('duty').placeholder='器材,商务,宣传,发行,赞助,后期'
        console.log('其他')
}    
}
	window.addEventListener('renovate', function(e){
		//裁剪后返回的图片显示在image标签下的img
		document.getElementById('image').src=e.detail.image;
				//主图裁剪上传返回数据执行更新
//			  location.reload(); //刷新
			  });
	function goimage() {
		tid=localStorage.itemtid;
		act='resume';
		method='resume';
		width=300;
		height=300;
		localStorage.image='{"tid":"'+tid+'","act":"up'+act+'","method":"'+method+'","src":"","width":'+width+',"height":'+height+'}';
		mui.openWindow('../Plugin/image/base64.html');
	};

function tijiao(){
	var sizenum=1;
	if(document.getElementById('synopsis').value.length<sizenum){
		alert('简介最少需要'+sizenum+'字，请从新提交');
//		return false;
	}
	// 得到页面中所有input	
	var allInputs = document.getElementsByTagName('input');
	var libIds = [];
	// 在所有Input中过滤出type="text" and name="libID"的元素，放到数组libIds中  && allInputs[i].name === 'libname'
//	for (var i = 0; i < allInputs.length; i++) {
//		if (allInputs[i].type === 'text' && allInputs[i].name === 'libname') 
//		{
//			libIds.push(allInputs[i]);	
//			if(allInputs[i].value==''){
//			alert('您有表单未填写，请填写后提交');
////			return false;
//			}
//		}
//	}

mui.post(home.hos+'/item/user',Object.assign(apptoken,{
		act:'publishteam',
		tid:localStorage.itemtid,
		confirm:document.getElementById('confirm').value,
		name:document.getElementById('name').value,
		class:document.getElementById('class').value,
		synopsis:document.getElementById('synopsis').value,
		duty:document.getElementById('duty').value,
		image:document.getElementById('image').src
}),function(data){
		if(data!=200){
			plus.ui.toast("发布失败,请重新尝试，错误码".data);
		}else{
				mui.back();
				var list = plus.webview.currentWebview().opener();
//	   	触发父页面的自定义事件(renovate),从而返回父页面更新,并且传递参数新图片值和id值
				mui.fire(list,'renovate',{image:document.getElementById('image').src,name:document.getElementById('name').value,class:document.getElementById('class').value,duty:document.getElementById('duty').value});
				//返回true,继续页面关闭逻辑
				return true;
				}
		//服务器返回响应，根据响应结果，分析是否登录成功；

	},'text'
);}
  </script>
  </body>
  </html>